<?php
import("Com.Auth");
class AuthAction extends Action//用户登录
{
	public function _initialize(){
		$this->assign('ano',Auth::getno());
    	$this->assign('aname',Auth::getname());
    	$this->assign('arole',Auth::getrole());
	}
    public function auth()
    {
    	$info=M("info");
    	$user = $info->find($_POST['no']);

    	if($user["password"]==$_POST['password']){
    		if($_POST['remember'])
    			Cookie::set('no',$_POST['no'],60*60*24);
    		else
    			Cookie::set('no',$_POST['no']);
    			if($_POST['url']!='')
					$this->ajaxReturn($_POST['url'],'登陆成功',1);
    		$this->ajaxReturn(0,'登陆成功',1);
    	}
    	$this->error('用户名或密码错误',1);
    }
    public function logout()
    {
    	Cookie::delete('no');
    	//if($_GET['url'])
    		//$this->redirect($_GET['url']);
    	$this->redirect("index/index");
    }
    public function logon()
    {
    	$this->assign('no',Auth::getno());
    	$this->assign('name',Auth::getname());
    	$this->assign('role',Auth::getrole());
    	$this->assign('url',$_GET['url']);
       	$this->display();
    }
}